﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
namespace SQT.tracnghiem.Ajax.ASP.Working
{
    public partial class load_working : System.Web.UI.Page
    {
        public int id;
        protected void Page_Load(object sender, EventArgs e)
        {
            id = int.Parse(Request.QueryString["id"]);

        }

        public int get_last_week(int id)
        {
            var last_week = (from p in new TblWeekController().FetchAll() orderby p.Id descending select p).ToList();
            int last = 0;
            for (int i = 0; i < last_week.Count; i++)
            {
                if (last_week[i].Id == id)
                {
                    last = last_week[i + 1].Id;
                    break;
                }
            }
            return last;
        }
        public int get_next_week(int id)
        {
            var next_week = (from p in new TblWeekController().FetchAll() orderby p.Id descending select p).ToList();
            int next = 0;
            if (next_week[0].Id != id)
            {
                for (int i = 1; i < next_week.Count; i++)
                {
                    if (next_week[i].Id == id)
                    {
                        next = next_week[i - 1].Id;
                        break;
                    }
                }
            }
            return next;
        }
    }
}